//
//  YXCaching.swift
//  
//
//  Created by tangbl93 on 2021/2/27.
//

import Foundation

// MARK: YXCaching protocol
public protocol YXCaching: NSObjectProtocol {
    
    func value(forKey key: String) -> Any?
    func value(forKey key: String, default object: Any) -> Any
    
    func set(_ value: Any?, forKey key: String)
    func transition(from oldKey: String, to newKey: String)
    
    func removeAll()
    func removeObject(forKey key: String)
}

// MARK: YXCachingStatic = YXCaching + static
public protocol YXCachingStatic {
    
    static func value(forKey key: String) -> Any?
    static func value(forKey key: String, default object: Any) -> Any
    
    static func set(_ value: Any?, forKey key: String)
    static func transition(from oldKey: String, to newKey: String)
    
    static func removeAll()
    static func removeObject(forKey key: String)
    
    
    // MARK: convert
    static func string(forKey key: String) -> String?
    
    static func integer(forKey key: String) -> Int
    
    static func float(forKey key: String) -> Float
    
    static func double(forKey key: String) -> Double
    
    static func bool(forKey key: String) -> Bool
    
    static func data(forKey key: String) -> Data?
    
    static func array(forKey key: String) -> [Any]?

    static func dictionary(forKey key: String) -> [String : Any]?

    static func stringArray(forKey key: String) -> [String]?
}
